﻿<?php
class Model_ProductDetails extends Zend_Db_Table_Abstract
{
	protected $_name = 'product_detail';

	public function createProductDetails ($p_id,$catdes_id,$pdetail_mota)
	{
		$rowProductDetail= $this->createRow();
		if ($rowProductDetail) {
			// update the row values
			$rowProductDetail->p_id = $p_id;
			$rowProductDetail->catdes_id = $catdes_id;
			$rowProductDetail->pdetail_mota = $pdetail_mota;
			$rowProductDetail->save();			
			//return the new product detail;			
			return $rowProduct;
		} else {
			throw new Zend_Exception("Không tạo được product detail này");
		}
	}
		
	public static function getProductDetails($p_id)
	{
		$productDetailModel = new self();
		$select = $productDetailModel->select();
		$select->order(array('pdetail_id'))
			   ->where('p_id =?',$p_id);	
		return $productDetailModel->fetchAll($select);
	}
   
   
    public function fetchByProductID($p_idg, 
	    $order = 'p_id DESC', $count=null)
	{
		$where = 'p_id = ' . (int)$p_idg;
		$order = 'p_id DESC';
		return $this->fetchAll($where, $order, $count);
	}
	
	
}